package com.bw.finance.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bw.finance.conf.ResponseResult;
import com.bw.finance.eneity.invest.EbankBackPlan;
import com.bw.finance.mapper.EbankBackPlanMapper;
import com.bw.finance.service.IEbankBackPlanService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lizhengqian
 * @since 2020-08-25
 */
@Service
public class EbankBackPlanServiceImpl extends ServiceImpl<EbankBackPlanMapper, EbankBackPlan> implements IEbankBackPlanService {

    @Resource
    private IEbankBackPlanService iEbankBackPlanService;

    private final Logger logger = LoggerFactory.getLogger(ServiceImpl.class);

    @Override
    public ResponseResult getlist(int id) {
        ResponseResult result = ResponseResult.FAIL();
        try {
            logger.info("开始查询还款计划");
            QueryWrapper<EbankBackPlan> queryWrapper = new QueryWrapper<>();
//            queryWrapper.lambda().eq(EbankBackPlan::getInvestId,id);
            queryWrapper.lambda().eq(EbankBackPlan::getInvestId,id).orderByDesc(EbankBackPlan::getBackDate);
            List<EbankBackPlan> list = iEbankBackPlanService.list(queryWrapper);
            result.setResult(list);
            result.setSuccess(true);
            result.setMessage("还款计划查询成功");
            logger.info("还款计划查询结束");
        }catch (Exception e){
            logger.error(e.toString());
            logger.error("还款计划查询异常");
        }
        return result ;
    }
}
